﻿using System;
using System.Collections.Generic;
using System.Text;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;

namespace XNAGuiLib.Core
{
    public class Provider
    {
        /// <summary>
        /// static Game reference set on construction of singleton
        /// </summary>
        private Game _game = null;

        /// <summary>
        /// static Provider reference for Singleton setup
        /// </summary>
        private static Provider _provider = null;

        /// <summary>
        /// default private constructor
        /// </summary>
        /// <param name="game">the game object reference for this provider</param>
        private Provider(Game game)
        {
            this._game = game;
        }

        #region Static Public Method - GetInstance(Game game)
        /// <summary>
        /// static method to provide or create the singleton reference for later usage
        /// </summary>
        /// <param name="game"></param>
        /// <returns></returns>
        public static Provider GetInstance(Game game)
        {
            if (_provider == null) _provider = new Provider(game);
            return _provider;
        }
        #endregion

        #region Public Method - GetSpriteBatch()
        /// <summary>
        /// creates and returns a new SpriteBatch based on the games GraphicsDevice
        /// </summary>
        /// <returns>a new SpriteBatch to use for drawing sprites</returns>
        public SpriteBatch GetSpriteBatch()
        {
            return new SpriteBatch(this._game.GraphicsDevice);
        }
        #endregion


        public GIComponent CreateGIC()
        {
            return new GIComponent(this._game);
        }



    }
}
